/**
 * 1
 *  
 * @Author : roryrywang
 * @DateTime : 24-8-24 下午8:29
 */

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;
    int f[n][n];
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            cin >> f[i][j];
        }
    }
    int res = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            int tmp = f[i][j];
            if (i > 0)tmp += f[i - 1][j];
            if (j > 0)tmp += f[i][j - 1];
            if (i < n - 1)tmp += f[i + 1][j];
            if (j < n - 1)tmp += f[i][j + 1];
            res = max(res, tmp);
        }
    }

    cout << res;

    return 0;
}